image uploading 您所在的位置:网站首页 CategoryImages image uploading

image uploading

2023-01-21 14:29| 来源: 网络整理| 查看: 265

User5076454 posted

Hi,

(1)Try below link to save your image as binary data in database and read the image from database.

http://www.beansoftware.com/ASP.NET-Tutorials/Save-Read-Image-Database.aspx

(2) You can try another way:

Just save name of the image in your database and save your image files in your application's particular folder like "/images". find below code for saving image.

.aspx code :

.aspx.cs code : if (updImg.HasFile)                     {                         FileInfo f1 = new FileInfo(PhysicalPath + CategoryImages + entity.AdvertiseImage);                         if (f1.Exists)                             f1.Delete();                         string newtempfile = Common.PageBase.ChangeFileName(updImg.FileName);                         updImg.PostedFile.SaveAs(Server.MapPath("~/") + CategoryImages + newtempfile);                         entity.AdvertiseImage = newtempfile;                     }

                   public static string ChangeFileName(string filename)         {             string newFileName;             string[] Substring;             char[] delimitdot = { '.' };             Substring = filename.Replace(" ", "").Split(delimitdot, 2);             return newFileName = RemoveSpecialCharactor(Substring[0]) + Common.PageBase.GetUTCdate().ToString("MMddyyyyhhmmssfff") + '.' + Substring[1];         }

On above code entity.AdvertiseImage will be saved in your database as Image name.

Now you can fatch image from the folder while displaying in gridview with the help of Imagename saved in database.

Hope this will help you and let me know if you need any further help.

Please mark it as answer if it helps you.

Thanks.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有